// pages/orderDetail/orderDetail.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    detail: [],
    parentName: [],
    res: [],
    index: "",
    son: [],
    key:"",
    videoList: [{
        id: 1,
        text: "IT及其他"
      },
      {
        id: 2,
        text: "消防"
      },
      {
        id: 3,
        text: "数据中心/机房"
      },
      {
        id: 4,
        text: "音视频"
      },
      {
        id: 5,
        text: "设备管理"
      },
      {
        id: 6,
        text: "信息设施"
      },
      {
        id: 7,
        text: "公共安全"
      },
      {
        id: 8,
        text: "建筑智能化综合"
      },

    ],
    videoProblem: [

      {
        id: 1,
        text: "系统调试"
      },
      {
        id: 2,
        text: "项目造价"
      },
      {
        id: 3,
        text: "项目设计"
      },
      {
        id: 4,
        text: "项目管理"
      },
      {
        id: 5,
        text: "工程安装"
      },

    ]

  },
  finish:function(){
    wx.navigateTo({
      url: '../orderPage/orderPage',
      success: function (e) {
        var page = getCurrentPages().pop();
        // if (page == undefined || page == null) return;
        page.onLoad()
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this;

    wx.request({
      url: 'https://www.xiaozheng8.com/serviceCate/findAll',
      method: "post",
      success: function(res) {

        var detail = res.data.data
        that.setData({
          detail: detail,
          res: detail
        })
        // console.log(res.data.data);
        console.log(that.data.res);
        for (var i = 0; i < that.data.res.length; i++) {
          if (that.data.res[i].id == that.data.index) {
            that.setData({
              son: that.data.res[i].smallCates
            })
            console.log(that.data.son)
          }
        }
      }
    })
    that.setData({
      index: wx.getStorageSync("parent")
    })
    console.log(that.data.index);

    // console.log(this.data.son)

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {
    // var that=this;





    // var son = this.data.res[this.data.index];
    // console.log(son);
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  },
  son: function(e) {
    var that = this;
    var name = [];
    var index = e.currentTarget.dataset.index;
    var name = e.currentTarget.dataset.name;
    console.log(index);
    wx.setStorageSync("son", index);
    this.setData({
      key: e.currentTarget.dataset.index
    })
    // wx.setStorageSync("sons", name)
    // wx.switchTab({
    //   url: '../order/order',
    //   success: function(e) {
    //     var page = getCurrentPages().pop();
    //     // if (page == undefined || page == null) return;
    //     page.onLoad();
    //   }
    // })
  }
})